/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.vistas;

/**
 *
 * @author Johnny
 */
public class DBRestore {
    public boolean backupDB(String pathBase, String dbName, String dbUserName, String dbPassword, String path) {
        String executeCmd = pathBase+"mysqldump -u " + dbUserName + " -p" + dbPassword + " --add-drop-database -B " + dbName + " -r " + path;
        Process runtimeProcess;
        try {
            System.out.println(executeCmd);
            runtimeProcess = Runtime.getRuntime().exec(executeCmd);
            int processComplete = runtimeProcess.waitFor();
 
            if (processComplete == 0) {
                System.out.println("Backup creado Correctamente");
                return true;
            } else {
                System.out.println("No se pudo crear el backup");
                return false;
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
 
        return false;
    }
}
